package v2

import (
	rpcv1 "gluenet/internal/agent/api/rpc/v1"
	"gluenet/pkg/agent/v2/rpc"
	"gluenet/utils/rpc/v2/define"
)

type DagGetter interface {
	Dag() GluenetDagInterface
}

type GluenetDagInterface interface {
	DagServiceMap(dagServiceMap *define.DagServiceMap) (result string, err error)
	DagResponse(dagServiceMap *define.DagResponse) (result define.DagResponseResp, err error)
}

type gluenetDag struct {
	client rpc.Interface
}

func newGluenetDag(c *CoreClient) *gluenetDag {
	return &gluenetDag{
		client: c.RPCClient(),
	}
}

func (c *gluenetDag) DagServiceMap(dagServiceMap *define.DagServiceMap) (result string, err error) {
	err = c.client.Invoke().
		Api(rpcv1.DagServiceMap).
		Spec(*dagServiceMap).
		Do().
		Into(&result)
	return
}

func (c *gluenetDag) DagResponse(dagResponse *define.DagResponse) (result define.DagResponseResp, err error) {
	err = c.client.Invoke().
		Api(rpcv1.DagResponse).
		Spec(*dagResponse).
		Do().
		Into(&result)
	return
}
